<?php
namespace app\cms\upgrade;

use think\Db;

class U4{
    public static function up(){
	    
	    query("ALTER TABLE  `qb_cms_content3` CHANGE  `mv_url`  `mv_url` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT  '视频地址'");
	    $array = Db::name('cms_content3')->column('id,title,mv_url');
	    foreach($array AS $rs){
	        $data = [
	                'mv_url'=>json_encode([
	                        [
	                                'url'=>$rs['mv_url'],
	                                'title'=>$rs['title']
	                        ],
	                ]),
	        ];
	        Db::name('cms_content3')->where('id',$rs['id'])->update($data);
	    }
	    query("UPDATE `qb_cms_field` SET  `type` =  'files2',`field_type` =  'text NOT NULL'  WHERE `name` = 'mv_url';");		  
	}
}


